'use strict';
define(function(require) {
    var toTopbutton = require('module/DirectiveModule');
    var exportData = {
        scope: {},
        restrict: 'AE',
        template: require('text!template/toTopbutton.html'),
        replace: true,
        controller: function($scope) {
            var $buttonDom = $('.toTopButton');
            $(window).on('scroll', function() {
                _.delay(function() {
                    $(window).scrollTop() !== 0 ? $buttonDom.fadeIn(200) : $buttonDom.fadeOut(200);
                }, 500);
            });
            $scope.toTopSlider = function() {
                jQuery('html, body').animate({
                    scrollTop: 0
                }, 200);
            };
        }
    };
    toTopbutton.directive('totopbutton', function() {
        return exportData;
    });
});